package com.base.vistter.iframe.inverter.controller;

import com.base.vistter.iframe.bean.Result;
import com.base.vistter.iframe.entity.InverterDevicesPowerYear;
import com.base.vistter.iframe.exception.IframeException;
import com.base.vistter.iframe.model.DevicesYearPowerRequest;
import com.base.vistter.iframe.service.InverterDevicesPowerYearService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/devices/power/year")
public class InverterDevicesPowerYearController {

    @Resource(name = "inverterDevicesPowerYearService")
    private InverterDevicesPowerYearService inverterDevicesPowerYearService;

    @PostMapping(value = "/statistics", produces = "application/json;charset=utf-8")
    public Result<List<InverterDevicesPowerYear>> statistics(@RequestBody DevicesYearPowerRequest devicesYearPowerRequest) throws IframeException {
        return Result.ok(inverterDevicesPowerYearService.statisticsDevices(devicesYearPowerRequest));
    }

}
